package com.plian.system.dao.cqzc.bondsapply;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import com.plian.system.model.page.Page;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
* 说明：发债申请
*/
@Component
public class  BondsApplyDao {
@Resource(name = "daoSupport")
private DaoSupport dao;

	/**
	* 新增
	* @param pd
	* @throws Exception
	*/
	public void save(PageData pd) throws Exception {
		dao.save("BondsApplyMapper.save",pd);
	}

	/**
	* 修改
	* @param pd
	* @throws Exception
	*/
	public void edit(PageData pd) throws Exception {
		dao.update("BondsApplyMapper.edit",pd);
	}

	/**
	* * 根据Id获取一条数据
	* @param id
	* @return
	* @throws Exception
	*/
	public PageData findbyid(String id) throws Exception {
		return (PageData) dao.findForObject("BondsApplyMapper.findbyid",id);
	}
	/**
	* 列表
	* @return
	* @throws Exception
	*/
	public List<PageData> listPage(Page page) throws Exception {
		return (List<PageData>) dao.findForList("BondsApplyMapper.listPage",page);
	}
	/**
	 * 列表
	 * @return
	 * @throws Exception
	 */
	public List<PageData> list(PageData pd) throws Exception {
		return (List<PageData>) dao.findForList("BondsApplyMapper.list",pd);
	}
	/**
	* 批量删除
	* @return
	* @throws Exception
	*/
	public void del_ids(List<String> ids) throws Exception {
		dao.delete("BondsApplyMapper.del_ids",ids);
	}
	/**
	* 修改状态
	* @param pd
	*/
	public void  refer(PageData pd) throws Exception {
		dao.update("BondsApplyMapper.refer",pd);
	}
	/**
	* 根据多个id查询
	* @param pd
	*/
	public List<PageData> findByIds(PageData pd) throws Exception {
		List<PageData> forList = (List<PageData>) dao.findForList("BondsApplyMapper.findByIds", pd);
		List<PageData> out = new ArrayList<>();
		for (PageData pd2 :forList){
			String unitname = pd2.getString("UNITNAME");
			pd2.put("orgName",unitname);
			out.add(pd2);
		}
		return out;
	}
	public List<PageData> reportListPage(Page page) throws Exception {
		return (List<PageData>) dao.findForList("BondsApplyMapper.reportListPage",page);
	}
}